<?php
/**
 * Created By Project
 * Author: 陈东
 * Copyright：陈东
 * Source Code：陈东
 * Explain：I shall not authorize for any other commercial purposes, law breakers must be prosecuted.
 */
namespace Admin\Controller;
use Think\Controller;

class BaseController extends Controller {
	/**
	 * 后台主页显示
	 */
	public function _initialize(){
// 		if(!strpos($_SERVER["HTTP_USER_AGENT"],"Chrome")){
// 			echo "<div style=\"color:#f00; font-size:15px; text-align:center; margin-top:24px;\">为保证后台能更好的展现效果，请使用谷歌Chrome浏览器或360浏览器极速模式</div>";
// 		}
		if(empty(session('userinfo'))) $this->redirect('Login/login');
		
		/*资源类型设定值*/
		$arraytype = explode(',', C('RESOURCE_TYPE'));
		$this->assign('arraytype',$arraytype);
	}
	
	/**
	 * 生成单个华人码
	 */
	public function qrcode($data=null){
		if(!empty($data)){
			vendor("phpqrcode.phpqrcode");
			$object = new \QRcode();
			$level=3;
			$size=4;
			//容错级别
			$errorCorrectionLevel =intval($level);
			//生成图片大小
			$matrixPointSize = intval($size);
			$path = "codeimg/";
			$fileName = $path.'code.png';
			$object->png($data, $fileName,  $errorCorrectionLevel, $matrixPointSize, 2);
			return $fileName;
		}else{
			return false;
		}

	}
	
	/**
	 * 批量生产华人码
	 */
	public function qrcodes($path,$data=null){
		if(!empty($data)){
			vendor("phpqrcode.phpqrcode");
			$object = new \QRcode();
			$level = 'H';
			$size = 20;
			//容错级别
			$errorCorrectionLevel =intval($level);
			//生成图片大小
			$matrixPointSize = intval($size);
			$object->png($data, $path,  $errorCorrectionLevel, $matrixPointSize, 2);
			return true;
		}else{
			return false;
		}
	
	}

	/**
	 * 模板定义
	 */
	public function tpl_select(){
		$tpl = array(
			array('key' => 1, 'idx' => 'index', 'name' => '模板一'),
			array('key' => 2, 'idx' => 'index2', 'name' => '模板二'),
			array('key' => 3, 'idx' => 'index3', 'name' => '模板三'),
			array('key' => 4, 'idx' => 'index4', 'name' => '模板四'),
			array('key' => 5, 'idx' => 'index5', 'name' => '模板五'),
			array('key' => 6, 'idx' => 'index6', 'name' => '模板六', 'des' => '（视频+简介）'),
			array('key' => 7, 'idx' => 'index7', 'name' => '模板七', 'des' => '（全图）'),
			array('key' => 8, 'idx' => 'index8', 'name' => '模板八', 'des' => '（内容直接展示）'),
			array('key' => 9, 'idx' => 'index9', 'name' => '模板九', 'des' => '（简版）'),
			array('key' => 10, 'idx' => 'index10', 'name' => '模板十', 'des' => ''),
		);
		return $tpl;
	}


}